<?php $this->load->view('layout/lib_chart');?>
		
		
		<?php 
			$maxheight=$row["sum_assured_death"];
			if ($row["sum_assured_disability"] > $maxheight)$maxheight = $row["sum_assured_disability"];
			if ($row["sum_assured_critical_illness"] > $maxheight)$maxheight = $row["sum_assured_critical_illness"];
			$row["policy_incepted"] = date('Y');
			$pit=$row["policy_incepted"]+$row["policy_term"];
			$policy_incepted	=	$row["policy_incepted"];
			$maxheight+=($maxheight*0.2);
			$current_year	=	date('Y');
			//print_r($row);
		?>

		
		
		<!-- 3. Add the container -->
		<div>Existing coverage <?php echo $param?></div>
		<?php if($row["step_up_booster"] != 1):?>
			<script type="text/javascript">
				var chart1,chart2,chart3,chart4;
				$(document).ready(function() {
					chart1 = new Highcharts.Chart({
						chart: {
							renderTo: 'container1',
							defaultSeriesType: 'spline',
							inverted: true,
							width: 400,
							style: {
								//margin: '0 auto'
							}
						},
						title: {
							text: 'Protection'
						},
						subtitle: {
							//text: 'According to the Standard Atmosphere Model'
						},
						xAxis: {
							reversed: false,
							title: {
								enabled: true,
								text: 'SAD'
							},
							labels: {
								formatter: function() {
									return this.value +'';
								}
							},
							maxPadding: 0.05,
							//showLastLabel: true,
							min : 0,
							max : <?php echo $maxheight;?>
						},
						yAxis: {
							title: {
								text: 'PI + t'
							},
							labels: {
								formatter: function() {
									return this.value + '';
								}
							},
							lineWidth: 1,
							gridLineWidth : 0,
							plotLines: [{
					            color: 'green',
					            width: 1,
					            value: <?php echo $current_year;?>,
					           	dashStyle: 'dash'
					        },
					        {
					            color: 'green',
					            width: 1,
					            value: <?php echo $pit;?>,
					           	dashStyle: 'dash'
					        }
					        ],
							min : <?php echo $current_year;?>,
							//categories:['2011','2040','2050']
						},
						legend: {
							enabled: false
						},
						tooltip: {
							formatter: function() {
								return ''+
									this.y +' / '+ this.x +'';
							}
						},
						plotOptions: {
							spline: {
								marker: {
									enable: false
								}
							}
						},
						series: [{
							name: 'Temperature',
							//data: [[<?php echo $row["sum_assured_death"];?>, <?php echo $current_year;?>], [<?php echo $row["sum_assured_death"];?>, <?php echo $pit;?>]]
							//data:[90000,90000,90000]
						}]
					});
	
					chart2 = new Highcharts.Chart({
						chart: {
							renderTo: 'container2',
							defaultSeriesType: 'spline',
							inverted: true,
							width: 400,
							style: {
								//margin: '0 auto'
							}
						},
						title: {
							text: 'Protection'
						},
						subtitle: {
							//text: 'According to the Standard Atmosphere Model'
						},
						xAxis: {
							reversed: false,
							title: {
								enabled: true,
								text: 'SADI'
							},
							labels: {
								formatter: function() {
									return this.value +'';
								}
							},
							maxPadding: 0.05,
							//showLastLabel: true,
							min : 0,
							max : <?php echo 200000;?>
						},
						yAxis: {
							title: {
								text: 'PI + t'
							},
							labels: {
								formatter: function() {
									return this.value + '';
								}
							},
							lineWidth: 2,
							min : <?php echo $policy_incepted;?>
						},
						legend: {
							enabled: false
						},
						tooltip: {
							formatter: function() {
								return ''+
									this.y +' / '+ this.x +'';
							}
						},
						plotOptions: {
							spline: {
								marker: {
									enable: false
								}
							}
						},
						series: [{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_disability"];?>, <?php echo $policy_incepted;?>], [<?php echo $row["sum_assured_disability"];?>, <?php echo $pit;?>]]
						}]
					});
	
					chart3 = new Highcharts.Chart({
						chart: {
							renderTo: 'container3',
							defaultSeriesType: 'spline',
							inverted: true,
							width: 400,
							style: {
								//margin: '0 auto'
							}
						},
						title: {
							text: 'Protection'
						},
						subtitle: {
							//text: 'According to the Standard Atmosphere Model'
						},
						xAxis: {
							reversed: false,
							title: {
								enabled: true,
								text: 'SACI',
								align: 'high'
							},
							labels: {
								formatter: function() {
									return this.value +'';
								}
							},
							maxPadding: 0.05,
							//showLastLabel: true,
							min : 0,
							max : <?php echo $maxheight;?>
						},
						yAxis: {
							title: {
								text: 'PI + t',
								align: 'high'
							},
							labels: {
								formatter: function() {
									return this.value + '';
								}
							},
							lineWidth: 2,
							min : <?php echo $policy_incepted;?>
						},
						legend: {
							enabled: false
						},
						tooltip: {
							formatter: function() {
								return ''+
									this.y +' / '+ this.x +'';
							}
						},
						plotOptions: {
							spline: {
								marker: {
									enable: false
								}
							}
						},
						series: [{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_critical_illness"];?>, <?php echo $policy_incepted;?>], [<?php echo $row["sum_assured_critical_illness"];?>, <?php echo $pit;?>]]
						}]
					});
					
				});
					
			</script>
			
			<script>
			var chart;
			$(document).ready(function() {
				chart = new Highcharts.Chart({
					chart: {
						renderTo: 'container3',
						defaultSeriesType: 'column'
					},
					title: {
						text: 'Monthly Average Rainfall'
					},
					subtitle: {
						text: 'Source: WorldClimate.com'
					},
					xAxis: {
						categories: [
							'Jan', 
							'Feb', 
							'Mar', 
							'Apr', 
							'May', 
							'Jun', 
							'Jul', 
							'Aug', 
							'Sep', 
							'Oct', 
							'Nov', 
							'Dec'
						]
					},
					yAxis: {
						min: 0,
						title: {
							text: 'Rainfall (mm)'
						}
					},
					legend: {
						layout: 'vertical',
						backgroundColor: '#FFFFFF',
						align: 'left',
						verticalAlign: 'top',
						x: 100,
						y: 70,
						floating: true,
						shadow: true
					},
					tooltip: {
						formatter: function() {
							return ''+
								this.x +': '+ this.y +' mm';
						}
					},
					plotOptions: {
						column: {
							pointPadding: 0.2,
							borderWidth: 0
						}
					},
				        series: [{
						name: 'Tokyo',
						data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
				
					}, {
						name: 'New York',
						data: [83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3]
				
					}, {
						name: 'London',
						data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2]
				
					}, {
						name: 'Berlin',
						data: [42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1]
				
					}]
				});
				
				
			});
				
		</script>
		<?php else:?>
			<script type="text/javascript">
				var chart1,chart2,chart3,chart4;
				$(document).ready(function() {
					chart1 = new Highcharts.Chart({
						chart: {
							renderTo: 'container1',
							defaultSeriesType: 'spline',
							inverted: true,
							width: 400,
							style: {
								//margin: '0 auto'
							}
						},
						title: {
							text: 'Protection'
						},
						subtitle: {
							//text: 'According to the Standard Atmosphere Model'
						},
						xAxis: {
							reversed: false,
							title: {
								enabled: true,
								text: 'SAD'
							},
							labels: {
								formatter: function() {
									return this.value +'';
								}
							},
							maxPadding: 0.05,
							//showLastLabel: true,
							min : 0,
							//max : <?php echo $maxheight;?>,
							plotLines: [{
				                value: <?php echo ($row["sum_assured_death"]+$row["addictional_sum_assured_death"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            },
				            {
				                value: <?php echo ($row["sum_assured_death"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }
				            ]
						},
						yAxis: {
							title: {
								text: 'PI + t'
							},
							labels: {
								formatter: function() {
									return this.value + '';
								}
							},
							lineWidth: 2,
							min : <?php echo $policy_incepted;?>,
							max : <?php echo ($row["policy_incepted"]+$row["policy_term"]);?>,
							plotLines: [{
				                value: <?php echo ($row["policy_incepted"]+$row["year_start"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            },
				            {
				                value: <?php echo ($row["policy_incepted"]+$row["year_end"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }
				            
				            ]
						},
						legend: {
							enabled: false
						},
						tooltip: {
							formatter: function() {
								return ''+
									this.y +' / '+ this.x +'';
							}
						},
						plotOptions: {
							spline: {
								marker: {
									enable: false
								}
							}
						},
						series: [{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_death"];?>, <?php echo $policy_incepted;?>], [<?php echo $row["sum_assured_death"];?>, <?php echo ($row["year_start"]);?>]]
						},
						{
							name: 'Temperature',
							data: [[<?php echo ($row["sum_assured_death"]+$row["addictional_sum_assured_death"]);?>, <?php echo ($row["year_start"]);?>],[<?php echo ($row["sum_assured_death"]+$row["addictional_sum_assured_death"]);?>, <?php echo ($row["year_end"]);?>]]
						},
						{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_death"];?>, <?php echo ($row["year_end"]);?>], [<?php echo $row["sum_assured_death"];?>, <?php echo ($row["retirement_age"]);?>]]
						}
						]
					});
	
					chart2 = new Highcharts.Chart({
						chart: {
							renderTo: 'container2',
							defaultSeriesType: 'spline',
							inverted: true,
							width: 400,
							style: {
								//margin: '0 auto'
							}
						},
						title: {
							text: 'Protection'
						},
						subtitle: {
							//text: 'According to the Standard Atmosphere Model'
						},
						xAxis: {
							reversed: false,
							title: {
								enabled: true,
								text: 'SADI'
							},
							labels: {
								formatter: function() {
									return this.value +'';
								}
							},
							maxPadding: 0.05,
							//showLastLabel: true,
							min : 0,
							//max : <?php echo $maxheight;?>,
							plotLines: [{
				                value: <?php echo ($row["sum_assured_disability"]+$row["addictional_sum_assured_disability"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            },
				            {
				                value: <?php echo ($row["sum_assured_disability"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }
				            ]
						},
						yAxis: {
							title: {
								text: 'PI + t'
							},
							labels: {
								formatter: function() {
									return this.value + '';
								}
							},
							lineWidth: 2,
							min : <?php echo $policy_incepted;?>,
							max : <?php echo ($row["policy_incepted"]+$row["policy_term"]);?>,
							plotLines: [{
				                value: <?php echo ($row["policy_incepted"]+$row["year_start"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            },
				            {
				                value: <?php echo ($row["policy_incepted"]+$row["year_end"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }
				            
				            ]
						},
						legend: {
							enabled: false
						},
						tooltip: {
							formatter: function() {
								return ''+
									this.y +' / '+ this.x +'';
							}
						},
						plotOptions: {
							spline: {
								marker: {
									enable: false
								}
							}
						},
						series: [{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_disability"];?>, <?php echo $policy_incepted;?>], [<?php echo $row["sum_assured_disability"];?>, <?php echo ($row["year_start"]);?>]]
						},
						{
							name: 'Temperature',
							data: [[<?php echo ($row["sum_assured_disability"]+$row["addictional_sum_assured_disability"]);?>, <?php echo ($row["year_start"]);?>],[<?php echo ($row["sum_assured_disability"]+$row["addictional_sum_assured_disability"]);?>, <?php echo ($row["year_end"]);?>]]
						},
						{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_disability"];?>, <?php echo ($row["year_end"]);?>], [<?php echo $row["sum_assured_disability"];?>, <?php echo ($row["retirement_age"]);?>]]
						}
						]
					});
	
					chart3 = new Highcharts.Chart({
						chart: {
							renderTo: 'container3',
							defaultSeriesType: 'spline',
							inverted: true,
							width: 400,
							style: {
								//margin: '0 auto'
							}
						},
						title: {
							text: 'Protection'
						},
						subtitle: {
							//text: 'According to the Standard Atmosphere Model'
						},
						xAxis: {
							reversed: false,
							title: {
								enabled: true,
								text: 'SACI',
								align: 'high'
							},
							labels: {
								formatter: function() {
									return this.value +'';
								}
							},
							maxPadding: 0.05,
							//showLastLabel: true,
							min : 0,
							//max : <?php echo $maxheight;?>,
							plotLines: [{
				                value: <?php echo ($row["sum_assured_critical_illness"]+$row["addictional_sum_assured_critical"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            },
				            {
				                value: <?php echo ($row["sum_assured_critical_illness"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }
				            ]
						},
						yAxis: {
							title: {
								text: 'PI + t',
								align: 'high'
							},
							labels: {
								formatter: function() {
									return this.value + '';
								}
							},
							lineWidth: 2,
							min : <?php echo $policy_incepted;?>,
							max : <?php echo ($row["policy_incepted"]+$row["policy_term"]);?>,
							plotLines: [{
				                value: <?php echo ($row["policy_incepted"]+$row["year_start"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            },
				            {
				                value: <?php echo ($row["policy_incepted"]+$row["year_end"]);?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }
				            
				            ]
						},
						legend: {
							enabled: false
						},
						tooltip: {
							formatter: function() {
								return ''+
									this.y +' / '+ this.x +'';
							}
						},
						plotOptions: {
							spline: {
								marker: {
									enable: false
								}
							}
						},
						series: [{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_critical_illness"];?>, <?php echo $policy_incepted;?>], [<?php echo $row["sum_assured_critical_illness"];?>, <?php echo ($row["year_start"]);?>]]
						},
						{
							name: 'Temperature',
							data: [[<?php echo ($row["sum_assured_critical_illness"]+$row["addictional_sum_assured_critical"]);?>, <?php echo ($row["year_start"]);?>],[<?php echo ($row["sum_assured_critical_illness"]+$row["addictional_sum_assured_critical"]);?>, <?php echo ($row["year_end"]);?>]]
						},
						{
							name: 'Temperature',
							data: [[<?php echo $row["sum_assured_critical_illness"];?>, <?php echo ($row["year_end"]);?>], [<?php echo $row["sum_assured_critical_illness"];?>, <?php echo ($row["retirement_age"]);?>]]
						}
						]
					});
					
				});
					
			</script>
		<?php endif;?>
		
		<?php if($row["consider_cash_value_retirement"] == 1):?>
			<script type="text/javascript">
				var chart4;
				$(document).ready(function() {
					chart4 = new Highcharts.Chart({
						chart: {
							renderTo: 'chart4',
							defaultSeriesType: 'spline',
							inverted: true,
							width: 400,
							style: {
								//margin: '0 auto'
							}
						},
						title: {
							text: 'Retirement'
						},
						subtitle: {
							//text: 'According to the Standard Atmosphere Model'
						},
						xAxis: {
							reversed: false,
							title: {
								enabled: true,
								text: 'MV',
								align: 'high'
							},
							labels: {
								formatter: function() {
									return this.value +'';
								}
							},
							maxPadding: 0.05,
							//showLastLabel: true,
							min : 0,
							plotLines: [{
				                value: <?php echo $row["cva_retirement"];?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }]
							//gridLineWidth: 1
						},
						yAxis: {
							title: {
								text: 'MY',
								//align: 'slow',
								//margin-left : 80
							},
							labels: {
								formatter: function() {
									return this.value + '';
								}
							},
							lineWidth: 2,
							min : <?php echo date('Y');?>,
							max : <?php echo $row["retirement_age"]+10?>,
							gridLineWidth: 0,
							plotLines: [{
				                value: <?php echo $row["retirement_age"];?>,
				                width: 1,
				                color: 'green',
				                dashStyle: 'dash',
				                label: {
				                    //text: 'Latest value',
				                    align: 'right',
				                    y: 12,
				                    x: 0
				                }
				            }]
						},
						legend: {
							enabled: false
						},
						tooltip: {
							formatter: function() {
								return ''+
									this.y +' / '+ this.x +'';
							}
						},
						plotOptions: {
							spline: {
								marker: {
									enable: false
								}
							}
						},
						series: [{
							name: 'Temperature',
							data: [[<?php echo $row["cva_retirement"];?>, <?php echo $row["retirement_age"];?>],[<?php echo $row["cva_retirement"];?>,<?php echo $row["retirement_age"]+10;?>]]
						}]
					});
				});
			</script>
		<?php endif;?>
		
		<table>
			<?php if($row["step_up_booster"] != 1):?>
			
			
			<tr>
				<td><div id="container1" style="width: 400px; height: 400px; margin: 0 auto"></div></td>
				<td><div id="container2" style="width: 400px; height: 400px; margin: 0 auto"></div></td>
				
			</tr>
			<?php else:?>
			
			<tr>
				<td><div id="container1" style="width: 400px; height: 400px; margin: 0 auto"></div></td>
				<td><div id="container2" style="width: 400px; height: 400px; margin: 0 auto"></div></td>
				
			</tr>
			<?php endif;?>
			
			<tr>
			<td><div id="container3" style="width: 400px; height: 400px; margin: 0 auto"></div></td>
			<?php
			if($row["consider_cash_value_retirement"] == 1):
			?>
				<td>
					<div id="chart4" style="width: 400px; height: 400px; margin: 0 auto"></div>
				</td>
			<?php
			endif;
			?>
			</tr>
			<tr>
				<td>
				<div id="container" style="width: 800px; height: 400px; margin: 0 auto"></div>
				</td>
			</tr>
			
		</table>
		
